package beans;

import java.beans.EventSetDescriptor;
import java.beans.IntrospectionException;
import java.beans.MethodDescriptor;
import java.beans.ParameterDescriptor;
import java.beans.SimpleBeanInfo;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

import Listeners.ImageListener;
import events.ImageEvent;

/**
 *
 * @author Marcel Meraner
 */
public class FilterBaseBeanBeanInfo extends SimpleBeanInfo {
    
    @Override
    public EventSetDescriptor[] getEventSetDescriptors(){
        
        try {
            String mnames[] = {"onImageProceed"};
            EventSetDescriptor esd = new EventSetDescriptor(FilterBaseBean.class, "image",
                    ImageListener.class, mnames, "addImageListener", "removeImageListener");
            
            EventSetDescriptor[] rv = {esd};
            
            return rv;
            
        } catch (IntrospectionException ex) {
            Logger.getLogger(FilterBaseBeanBeanInfo.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
    
    @Override
    public MethodDescriptor[] getMethodDescriptors() {
        try {
            Class c = FilterBaseBean.class;
            Class parameterTypes[] = new Class[1];
            parameterTypes[0] = ImageEvent.class;
            String name = "onImageProceed";
            Method method1;
            method1 = c.getMethod(name, parameterTypes);
            ParameterDescriptor pds[] = new ParameterDescriptor[1];
            pds[0] = new ParameterDescriptor();
            MethodDescriptor md1 = new MethodDescriptor(method1, pds);
            MethodDescriptor mds[] = { md1 };
            return mds;
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(FilterBaseBeanBeanInfo.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(FilterBaseBeanBeanInfo.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return null;
    }
    
}
